Pawn (scripting language)

PAWN
Appeared in 1998
Developer ITB CompuPhase
Stable release 4.0.4548 (1 August 2011[1])
Influenced by Small-C[2]
OS Cross-platform
License zlib License
Website www.compuphase.com/pawn/pawn.htm

Pawn, formerly known as Small, is an open source scripting language primarily intended as an embeddable scripting language. It is maintained by a Dutch company named CompuPhase, which released the first version in 1998.[3] The language was known as Small until version 3 was released in March 2005.[3]

Pawn is a typeless language influenced by Small-C. and has C-like syntax[4]

Pawn is used in the San Andreas Multiplayer mod, Half-Life mod, AMX Mod X and Source Engine based SourceMod as well as various other projects.[5]

Contents

Design

Pawn code is compiler-oriented. Source code of a Pawn script is kept in a file that has the 'pwn' extension, the contents are equivalent to what would be used in a Textfile, you can read the contents and edit them in various IDEs, as well as in a regular text editor such as Notepad.

The Pawn compiler compiles the source code to P-code (or bytecode) that will be written to a file with 'amx' extension.

Features

Uses

Grand Theft Auto: San Andreas Multiplayer

A common use for Pawn is in the popular unofficial Grand Theft Auto: San Andreas modification "San Andreas Multiplayer". This allows server hosts to enable their scripts to perform all the tasks available to players of the single player version of "Grand Theft Auto: San Andreas". This is made possible by the ability for server hosts to create their own "game modes" with the PAWN compiler. The implementation of the PAWN language also allows users to interact with the game in ways previously not possible in the single player environment.

Side-script design

PAWN is designed to be used as a side-script with code from other languages. PAWN does not ship with native functions which can be used for developing, instead Pawn's functions come from "include" files.

Code Examples

Here is an example of code that will print 4 random digits.

#include <core>
main() {
    new digit[4];//Introduces a new variable with an individual digit size of 4.
    for(new i=0;i<4;i++)//Will loop 4 times to fill the var 'digit.'
    {
        digit[i] = random(5000);//Gives the digit a random number in between 0 and 5000.
        printf("Digit %d's value is %d.", i, digit[i]);//Prints the digit and the digit's value on screen.
    }
    return 1;//Returns the number 1.
}

Here is a 'Hello World!' example.

#include <core>
main() {
    print("Hello World!");
}

References

External links